<html manifest="bootstrap.manifest">
  <head>
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript">
      
      Array.prototype.remove=function(s){
        var index = this.indexOf(s);
        if(index!= -1) {this.splice(index, 1)};
      }
    
      var localWrite=function(name, value){
      localStorage.setItem(name, JSON.stringify(value));
    }

    var localRead=function(name){
     return JSON.parse(  localStorage.getItem(name));
    }

      var storedNames=JSON.parse(localStorage['names']);
      $(function(){
          window.addEventListener('message', function(ev) {
            if (!ev || !ev.data || !ev.data.name) { return;}
            var data=ev.data;
            if(data.name!=="MaxiredBookmarks_down" && !data.page){
            return;
            }
            var mybookmarks = localRead("bookmarks")||[];
            if(data.type==="ADD"){
              mybookmarks.push(data.page);
            }else if(data.type==="RMV"){
            mybookmarks.remove(data.page);     
            }
            localWrite("bookmarks",mybookmarks);
            });
          var mybookmarks = localRead("bookmarks")||[];
          var toSend={};
          toSend.name="MaxiredBookmarks_up";
          toSend.pages=mybookmarks; 
          window.parent.postMessage(toSend,"*"); 


          });
</script> 
  </head>
</html>
